package com.unisal.java;

import java.util.Observable;
import java.util.Observer;

public class MostraCondicoesAtuaisWithObservable implements MostraElementos, Observer {

	@SuppressWarnings("unused")
	private Observable observable;
	private Double temperatura;
	private Double humidade;

	public MostraCondicoesAtuaisWithObservable(Observable observable) {
		this.observable = observable;
		observable.addObserver(this);
	}

	@Override
	public void mostra() {
		System.out.println("Condicoes atuais: " + this.temperatura
				+ " F graus  e " + this.humidade + "% de humidade.");

	}

	@Override
	public void update(Observable observable, Object arg) {
		if ( observable instanceof WeatherDataWithObservable){
			WeatherDataWithObservable weatherData = (WeatherDataWithObservable)observable;
			this.temperatura = weatherData.getTemperatura();
			this.humidade    = weatherData.getHumidade();
			mostra();
		}
		
	}

}
